
* Paper: 		Inflation and individual investors' behavior: 
*				Evidence from the German hyperinflation

* Authors: 		Fabio Braggion, Tilburg University
* 				Felix von Meyerinck, University of Zurich
* 				Nic Schaub, WHU – Otto Beisheim School of Management

* Description: 	This source code generates the tables and the figures in the 
*				main part of the paper. GermanHyperinflationClientLevel.dta,
*				GermanHyperinflationFirmLevel.dta, and 
*				GermanHyperinflationSecurityLevel.dta contain pseudo data. 
*				Results based on these data are not meaningful. 
*				GermanHyperinflationTownLevel.dta and 
*				GermanHyperinflationNominalPrices.dta contain real data.

set more off
  
*------------------------------------------------------------------------------
* Table 1: Descriptive statistics
*------------------------------------------------------------------------------

use "GermanHyperinflationClientLevel.dta", clear

* Keep only one observation per client (last observation)
gsort ClientNr -Month
by ClientNr: gen Counter = _n
keep if Counter == 1
drop Counter

* Rescale variables
replace PercentageEquityAvg = PercentageEquityAvg * 100
label var PercentageEquityAvg "Avg.\ \% stocks"
replace PercentageDebtAvg = PercentageDebtAvg * 100
label var PercentageDebtAvg "Avg.\ \% bonds"
replace PercentageForexAvg = PercentageForexAvg * 100
label var PercentageForexAvg "Avg.\ \% foreign exchange"
replace PercentageBuysPerMAvg = PercentageBuysPerMAvg * 100
label var PercentageBuysPerMAvg "Avg.\ \% buys"
replace PercentageStockTradesPerMAvg = PercentageStockTradesPerMAvg * 100
label var PercentageStockTradesPerMAvg "Avg.\ \% stock trades"
replace PercentageBondTradesPerMAvg = PercentageBondTradesPerMAvg * 100
label var PercentageBondTradesPerMAvg "Avg.\ \% bond trades"
replace PercentageForexTradesPerMAvg = PercentageForexTradesPerMAvg * 100
label var PercentageForexTradesPerMAvg "Avg.\ \% foreign exchange trades"

* Panel A: Client characteristics
eststo clear

quietly: estpost summarize Male Germany Europe RelationshipWithOtherBank, det

* Generate Latex output
esttab using "tables/table1A.tex", replace ///
cells("mean(fmt(%9.2fc) label(Mean)) min(label(Min)) p50(label(Median)) max(label(Max)) sd(label(St.Dev.)) count(fmt(%9.0fc) label(N))") ///
label nonumbers collabels(none) noobs booktabs f nomtitles plain



* Panel B: Portfolio characteristics
eststo clear

quietly: estpost summarize NumberOfSecuritiesInPortfolioAvg PercentageEquityAvg PercentageDebtAvg PercentageForexAvg, det

* Generate Latex output
esttab using "tables/table1B.tex", replace ///
cells("mean(fmt(%9.2fc) label(Mean)) min(label(Min)) p50(label(Median)) max(label(Max)) sd(label(St.Dev.)) count(fmt(%9.0fc) label(N))") ///
label nonumbers collabels(none) noobs booktabs f nomtitles plain



* Panel C: Trade characteristics

quietly: estpost summarize NumberOfTradesPerMAvg ///
PercentageBuysPerMAvg PercentageStockTradesPerMAvg PercentageBondTradesPerMAvg PercentageForexTradesPerMAvg ///
StockBuySellImbalancePerMAvg BondBuySellImbalancePerMAvg ForexBuySellImbalancePerMAvg, det

* Generate Latex output
esttab using "tables/table1C.tex", replace ///
cells("mean(fmt(%9.2fc) label(Mean)) min(label(Min)) p50(label(Median)) max(label(Max)) sd(label(St.Dev.)) count(fmt(%9.0fc) label(N))") ///
label nonumbers collabels(none) noobs booktabs f nomtitles plain



* Panel D: Firm characteristics
use "GermanHyperinflationFirmLevel.dta", clear

* Keep only one observation per firm
sort IssuerNr Month
by IssuerNr: gen Counter = _n
keep if Counter == 1
drop Counter

* Rescale variables
replace PercentageNetDebtAvg = PercentageNetDebtAvg * 100
label var PercentageNetDebtAvg "Avg.\ net leverage (\%)"
replace ChangePercentageNetDebtAvg = ChangePercentageNetDebtAvg * 100
label var ChangePercentageNetDebtAvg "Avg.\ $\Delta$ net leverage (\%)"

quietly: estpost summarize PercentageNetDebtAvg ChangePercentageNetDebtAvg, det

* Generate Latex output
esttab using "tables/table1D.tex", replace ///
cells("mean(fmt(%9.2fc) label(Mean)) min(label(Min)) p50(label(Median)) max(fmt(%12.2fc) label(Max)) sd(label(St.Dev.)) count(fmt(%9.0fc) label(N))") ///
label nonumbers collabels(none) noobs booktabs f nomtitles plain



* Panel E: Local inflation
use "GermanHyperinflationTownLevel.dta", clear

* Rescale variables
replace Inflation = Inflation * 100
label var Inflation "Raw local inflation (\%)"

* Winsorize
sum Inflation, det
winsor Inflation, gen(tmp) p(0.01)
replace Inflation = tmp
drop tmp
sum Inflation, det

quietly: estpost summarize Inflation, det

* Generate Latex output
esttab using "tables/table1E.tex", replace ///
cells("mean(fmt(%9.2fc) label(Mean)) min(label(Min)) p50(label(Median)) max(fmt(%12.2fc) label(Max)) sd(label(St.Dev.)) count(fmt(%9.0fc) label(N))") ///
label nonumbers collabels(none) noobs booktabs f nomtitles plain



*------------------------------------------------------------------------------
* Table 2: Determinants of local inflation
*------------------------------------------------------------------------------

use "GermanHyperinflationTownLevel.dta", clear

* Restrict sample to January 1920 to September 1923
drop if Month < ym(1920,1)
drop if Month > ym(1923,9)

* Generate numerical IDs
egen MonthID = group(Month)
egen TownID = group(Town)

* Winsorize
sum PercentageOfEmployeesPaper1921, det
winsor PercentageOfEmployeesPaper1921, gen(tmp) p(0.01)
replace PercentageOfEmployeesPaper1921 = tmp
drop tmp
sum PercentageOfEmployeesPaper1921, det

eststo clear

* Dependent variable: Local inflation
* Population
reghdfe InflationIHS ///
LnPopulation1919 ///
, noabsorb cluster(TownID MonthID)
eststo Inflation1

* Occupied
reghdfe InflationIHS ///
Occupied ///
, noabsorb cluster(TownID MonthID)
eststo Inflation2

* Unemployment
reghdfe InflationIHS ///
UnemploymentRateImputed ///
, noabsorb cluster(TownID MonthID)
eststo Inflation3

* German central bank
reghdfe InflationIHS ///
Reichsbank1920 ///
, noabsorb cluster(TownID MonthID)
eststo Inflation4

* Paper industry
reghdfe InflationIHS ///
PercentageOfEmployeesPaper1921 ///
, noabsorb cluster(TownID MonthID)
eststo Inflation5

* With all variables
reghdfe InflationIHS ///
LnPopulation1919 ///
Occupied ///
UnemploymentRateImputed ///
Reichsbank1920 ///
PercentageOfEmployeesPaper1921 ///
, noabsorb cluster(TownID MonthID)
eststo Inflation6

* With time and town fixed effects
reghdfe InflationIHS ///
Occupied ///
UnemploymentRateImputed ///
, absorb(TownID MonthID) cluster(TownID MonthID)
eststo Inflation7



estout using "tables/table2A.tex", replace ///
keep( ) ///
style(tex) label numbers mlabels(, none) collabels(, none) margin eqlabels(none) ///
posthead(\hline) ///
cells(b(star fmt(%9.3f)) t(par fmt(%9.2f))) ///
starlevels(* 0.10 ** 0.05 *** 0.01)

estout using "tables/table2B.tex", replace ///
keep(LnPopulation1919 ///
Occupied ///
UnemploymentRateImputed ///
Reichsbank1920 ///
PercentageOfEmployeesPaper1921) ///
eqlabels(none) ///
style(tex) label mlabels(, none) collabels(, none) margin ///
cells(b(star fmt(%9.3f)) t(par fmt(%9.2f))) ///
starlevels(* 0.10 ** 0.05 *** 0.01)

estout using "tables/table2C.tex", replace ///
keep( ) ///
style(tex) label mlabels(, none) collabels(, none) margin eqlabels(none) ///
cells(b(star fmt(%9.3f)) t(par fmt(%9.2f))) ///
starlevels(* 0.10 ** 0.05 *** 0.01) ///
stats(r2_a N, labels("Adj. R\textsuperscript{2}" "N") fmt(%9.3fc %9.0fc))



*------------------------------------------------------------------------------
* Table 3: Local inflation and stock trades
*------------------------------------------------------------------------------

use "GermanHyperinflationClientLevel.dta", clear

* Restrict sample to January 1920 to September 1923
drop if Month < ym(1920,1)
drop if Month > ym(1923,9)

* The place for which we have inflation data has to be in a 25km radius of where the client lives
drop if DistanceToTown > 25

* Keep only German clients
keep if Country == "Germany"

* Drop clients who do not trade
drop if NumberOfTrades == 0

* Generate numerical IDs
egen ClientID = group(ClientNr)
egen MonthID = group(Month)
egen TownID = group(Town)

eststo clear

* Dependent variable: Buy-sell imbalance for stocks
* With time fixed effects
reghdfe StockBuySellImbalancePerM ///
InflationIHS ///
, absorb(MonthID) cluster(TownID MonthID) keepsingletons
eststo Inflation1

* With time and client fixed effects
reghdfe StockBuySellImbalancePerM ///
InflationIHS ///
, absorb(ClientID MonthID) cluster(TownID MonthID) keepsingletons
eststo Inflation2

* Past 2-month inflation
reghdfe StockBuySellImbalancePerM ///
InflationPast2MIHS ///
, absorb(ClientID MonthID) cluster(TownID MonthID) keepsingletons
eststo Inflation3

* With time and client fixed effects and controls
reghdfe StockBuySellImbalancePerM ///
InflationIHS ///
Occupied UnemploymentRateImputed ///
, absorb(ClientID MonthID) cluster(TownID MonthID) keepsingletons
eststo Inflation4

* January 1920 to June 1922
reghdfe StockBuySellImbalancePerM ///
InflationIHS ///
if Month >= ym(1920,1) & Month <= ym(1922,6) ///
, absorb(ClientID MonthID) cluster(TownID MonthID) keepsingletons
eststo Inflation5

* July 1922 to September 1923
reghdfe StockBuySellImbalancePerM ///
InflationIHS ///
if Month >= ym(1922,7) & Month <= ym(1923,9) ///
, absorb(ClientID MonthID) cluster(TownID MonthID) keepsingletons
eststo Inflation6



estout using "tables/table3A.tex", replace ///
keep( ) ///
style(tex) label numbers mlabels(, none) collabels(, none) margin eqlabels(none) ///
posthead(\hline) ///
cells(b(star fmt(%9.3f)) t(par fmt(%9.2f))) ///
starlevels(* 0.10 ** 0.05 *** 0.01)

estout using "tables/table3B.tex", replace ///
keep(InflationIHS InflationPast2MIHS) ///
eqlabels(none) ///
style(tex) label mlabels(, none) collabels(, none) margin ///
cells(b(star fmt(%9.3f)) t(par fmt(%9.2f))) ///
starlevels(* 0.10 ** 0.05 *** 0.01)

estout using "tables/table3C.tex", replace ///
keep(Occupied UnemploymentRateImputed) ///
eqlabels(none) ///
style(tex) label mlabels(, none) collabels(, none) margin ///
cells(b(star fmt(%9.3f)) t(par fmt(%9.2f))) ///
starlevels(* 0.10 ** 0.05 *** 0.01)

estout using "tables/table3D.tex", replace ///
keep( ) ///
style(tex) label mlabels(, none) collabels(, none) margin eqlabels(none) ///
cells(b(star fmt(%9.3f)) t(par fmt(%9.2f))) ///
starlevels(* 0.10 ** 0.05 *** 0.01) ///
stats(r2_a N, labels("Adj. R\textsuperscript{2}" "N") fmt(%9.3fc %9.0fc))



*------------------------------------------------------------------------------
* Table 4: Local inflation and stock trades around the currency reform
*------------------------------------------------------------------------------

use "GermanHyperinflationClientLevel.dta", clear

* Restrict sample to January 1920 to December 1924
drop if Month < ym(1920,1)
drop if Month > ym(1924,12)

* The place for which we have inflation data has to be in a 25km radius of where the client lives
*drop if DistanceToTown > 25

* Keep only German clients
*keep if Country == "Germany"

* Drop clients who do not trade
drop if NumberOfTrades == 0

* Generate numerical IDs
egen ClientID = group(ClientNr)
egen MonthID = group(Month)
egen TownID = group(Town)

* Interaction variables
gen Germany_PostStabilization = Germany * PostStabilization
label var Germany_PostStabilization "Germany (d)$^{}_{i}$ $\times$ Post reform (d)$^{}_{t}$"

gen InflationSep23_PostStabilization = InflationPast6MIHSSep23 * PostStabilization
label var InflationSep23_PostStabilization "Local inflation$^{}_{i,Apr.-Sep.~1923}$ $\times$ Post reform (d)$^{}_{t}$"

eststo clear

* Dependent variable: Buy-sell imbalance for stocks
* Within Germany
reghdfe StockBuySellImbalancePerM ///
InflationSep23_PostStabilization ///
if DistanceToTown <= 25 & !mi(DistanceToTown) & Germany == 1 & Month >= ym(1923,4) & Month <= ym(1924,3) ///
, absorb(ClientID MonthID) cluster(TownID MonthID) keepsingletons
eststo Inflation1

* Germany vs. neighboring countries
reghdfe StockBuySellImbalancePerM Germany_PostStabilization if (Germany == 1 | NeighboringCountry == 1) & Month >= ym(1923,4) & Month <= ym(1924,3) ///
, absorb(ClientID MonthID) cluster(TownID MonthID) keepsingletons
eststo Inflation2



estout using "tables/table4A.tex", replace ///
keep( ) ///
style(tex) label numbers mlabels(, none) collabels(, none) margin eqlabels(none) ///
posthead(\hline) ///
cells(b(star fmt(%9.3f)) t(par fmt(%9.2f))) ///
starlevels(* 0.10 ** 0.05 *** 0.01)

estout using "tables/table4B.tex", replace ///
keep(Germany_PostStabilization ///
InflationSep23_PostStabilization) ///
eqlabels(none) ///
style(tex) label mlabels(, none) collabels(, none) margin ///
cells(b(star fmt(%9.3f)) t(par fmt(%9.2f))) ///
starlevels(* 0.10 ** 0.05 *** 0.01)

estout using "tables/table4C.tex", replace ///
keep( ) ///
style(tex) label mlabels(, none) collabels(, none) margin eqlabels(none) ///
cells(b(star fmt(%9.3f)) t(par fmt(%9.2f))) ///
starlevels(* 0.10 ** 0.05 *** 0.01) ///
stats(r2_a N, labels("Adj. R\textsuperscript{2}" "N") fmt(%9.3fc %9.0fc))



*------------------------------------------------------------------------------
* Table 5: Local inflation, client characteristics, and stock trades
*------------------------------------------------------------------------------

use "GermanHyperinflationClientLevel.dta", clear

* Restrict sample to January 1920 to September 1923
drop if Month < ym(1920,1)
drop if Month > ym(1923,9)

* The place for which we have inflation data has to be in a 25km radius of where the client lives
drop if DistanceToTown > 25

* Keep only German clients
keep if Country == "Germany"

* Drop clients who do not trade
drop if NumberOfTrades == 0

* Generate numerical IDs
egen ClientID = group(ClientNr)
egen MonthID = group(Month)
egen TownID = group(Town)

* Interaction variables
gen InflationIHS_Wealthy1920 = InflationIHS * Wealthy1920
label var InflationIHS_Wealthy1920 "Local inflation$^{}_{i,t}$ $\times$ Wealthy (d)$^{}_{i,Jan.~1920}$"

gen InflationIHS_DiversifiedStocks20 = InflationIHS * Diversified1920
label var InflationIHS_DiversifiedStocks20 "Local inflation$^{}_{i,t}$ $\times$ Diversified (d)$^{}_{i,Jan.~1920}$"

gen InflationIHS_Employee = InflationIHS * EmployeeOfBank
label var InflationIHS_Employee "Local inflation$^{}_{i,t}$ $\times$ Bank employee (d)$^{}_{i}$"

gen InflationIHS_MarginAccount = InflationIHS * MarginAccount
label var InflationIHS_MarginAccount "Local inflation$^{}_{i,t}$ $\times$ Levered (d)$^{}_{i}$"

eststo clear

* Dependent variable: Buy-sell imbalance for stocks
* Wealthy
reghdfe StockBuySellImbalancePerM ///
InflationIHS InflationIHS_Wealthy1920 ///
, absorb(ClientID MonthID) cluster(TownID MonthID) keepsingletons
eststo Inflation1

* Diversified
reghdfe StockBuySellImbalancePerM ///
InflationIHS InflationIHS_DiversifiedStocks20 ///
, absorb(ClientID MonthID) cluster(TownID MonthID) keepsingletons
eststo Inflation2

* Bank employee
reghdfe StockBuySellImbalancePerM ///
InflationIHS InflationIHS_Employee ///
, absorb(ClientID MonthID) cluster(TownID MonthID) keepsingletons
eststo Inflation3

* Margin account
reghdfe StockBuySellImbalancePerM ///
InflationIHS InflationIHS_MarginAccount ///
, absorb(ClientID MonthID) cluster(TownID MonthID) keepsingletons
eststo Inflation4



estout using "tables/table5A.tex", replace ///
keep( ) ///
style(tex) label numbers mlabels(, none) collabels(, none) margin eqlabels(none) ///
posthead(\hline) ///
cells(b(star fmt(%9.2f)) t(par fmt(%9.2f))) ///
starlevels(* 0.10 ** 0.05 *** 0.01)

estout using "tables/table5B.tex", replace ///
keep(InflationIHS ///
InflationIHS_Wealthy1920 ///
InflationIHS_DiversifiedStocks20 ///
InflationIHS_Employee ///
InflationIHS_MarginAccount) ///
eqlabels(none) ///
style(tex) label mlabels(, none) collabels(, none) margin ///
cells(b(star fmt(%9.3f)) t(par fmt(%9.2f))) ///
starlevels(* 0.10 ** 0.05 *** 0.01)

estout using "tables/table5C.tex", replace ///
keep( ) ///
style(tex) label mlabels(, none) collabels(, none) margin eqlabels(none) ///
cells(b(star fmt(%9.3f)) t(par fmt(%9.2f))) ///
starlevels(* 0.10 ** 0.05 *** 0.01) ///
stats(r2_a N, labels("Adj. R\textsuperscript{2}" "N") fmt(%9.3fc %9.0fc))



*------------------------------------------------------------------------------
* Table 6: Local inflation, stock characteristics, and stock trades
*------------------------------------------------------------------------------

* Low-yield stocks
use "GermanHyperinflationClientLevel.dta", clear

* Restrict sample to January 1920 to September 1923
drop if Month < ym(1920,1)
drop if Month > ym(1923,9)

* The place for which we have inflation data has to be in a 25km radius of where the client lives
drop if DistanceToTown > 25

* Keep only German clients
keep if Country == "Germany"

* Drop clients who do not trade
drop if NumberOfTrades == 0

* Generate numerical IDs
egen ClientID = group(ClientNr)
egen MonthID = group(Month)
egen TownID = group(Town)

eststo clear

* Dependent variable: Buy-sell imbalance for low-yield stocks
reghdfe LowYieldBuySellImbalancePerM ///
InflationIHS ///
, absorb(ClientID MonthID) cluster(TownID MonthID) keepsingletons
eststo Inflation1

* Compare coefficient estimates of low-yield stocks and high-yield stocks
preserve
keep ClientNr Month LowYieldBuySellImbalancePerM InflationIHS ///
ClientID MonthID TownID

rename LowYieldBuySellImbalancePerM LowHighYieldBuySellImbalancePerM

gen HighYield = 0

save "LowYieldStocksClientLevel.dta", replace
restore



* High-yield stocks
use "GermanHyperinflationClientLevel.dta", clear

* Restrict sample to January 1920 to September 1923
drop if Month < ym(1920,1)
drop if Month > ym(1923,9)

* The place for which we have inflation data has to be in a 25km radius of where the client lives
drop if DistanceToTown > 25

* Keep only German clients
keep if Country == "Germany"

* Drop clients who do not trade
drop if NumberOfTrades == 0

* Generate numerical IDs
egen ClientID = group(ClientNr)
egen MonthID = group(Month)
egen TownID = group(Town)

*eststo clear

* Dependent variable: Buy-sell imbalance for high-yield stocks
reghdfe HighYieldBuySellImbalancePerM ///
InflationIHS ///
, absorb(ClientID MonthID) cluster(TownID MonthID) keepsingletons
eststo Inflation2

* Compare coefficient estimates of low-yield stocks and high-yield stocks
preserve
keep ClientNr Month HighYieldBuySellImbalancePerM InflationIHS ///
ClientID MonthID TownID

rename HighYieldBuySellImbalancePerM LowHighYieldBuySellImbalancePerM

gen HighYield = 1

save "HighYieldStocksClientLevel.dta", replace
restore



* Compare coefficient estimates of low-yield stocks and high-yield stocks
use "LowYieldStocksClientLevel.dta", clear

append using "HighYieldStocksClientLevel.dta"

* Generate numerical IDs
egen MonthYieldID = group(MonthID HighYield)
egen ClientYieldID = group(ClientID HighYield)
egen TownYieldID = group(TownID HighYield)

* Interaction variables
gen InflationIHS_HighYield = InflationIHS * HighYield
label var InflationIHS_HighYield "Local inflation$^{}_{i,t}$ $\times$ High yield (d)"

*eststo clear

* Dependent variable: Buy-sell imbalance for low-yield/high-yield stocks
reghdfe LowHighYieldBuySellImbalancePerM ///
InflationIHS InflationIHS_HighYield ///
, absorb(ClientYieldID MonthYieldID) cluster(TownYieldID MonthYieldID) keepsingletons

test _b[InflationIHS_HighYield] = 0

erase "LowYieldStocksClientLevel.dta"
erase "HighYieldStocksClientLevel.dta"



* High-tech stocks
use "GermanHyperinflationClientLevel.dta", clear

* Restrict sample to January 1920 to September 1923
drop if Month < ym(1920,1)
drop if Month > ym(1923,9)

* The place for which we have inflation data has to be in a 25km radius of where the client lives
drop if DistanceToTown > 25

* Keep only German clients
keep if Country == "Germany"

* Drop clients who do not trade
drop if NumberOfTrades == 0

* Generate numerical IDs
egen ClientID = group(ClientNr)
egen MonthID = group(Month)
egen TownID = group(Town)

*eststo clear

* Dependent variable: Buy-sell imbalance for high-tech stocks
reghdfe HighTechBuySellImbalancePerM ///
InflationIHS ///
, absorb(ClientID MonthID) cluster(TownID MonthID) keepsingletons
eststo Inflation3

* Compare coefficient estimates of low-tech stocks and high-tech stocks
preserve
keep ClientNr Month HighTechBuySellImbalancePerM InflationIHS ///
ClientID MonthID TownID

rename HighTechBuySellImbalancePerM LowHighTechBuySellImbalancePerM

gen HighTech = 1

save "HighTechStocksClientLevel.dta", replace
restore



* Low-tech stocks
use "GermanHyperinflationClientLevel.dta", clear

* Restrict sample to January 1920 to September 1923
drop if Month < ym(1920,1)
drop if Month > ym(1923,9)

* The place for which we have inflation data has to be in a 25km radius of where the client lives
drop if DistanceToTown > 25

* Keep only German clients
keep if Country == "Germany"

* Drop clients who do not trade
drop if NumberOfTrades == 0

* Generate numerical IDs
egen ClientID = group(ClientNr)
egen MonthID = group(Month)
egen TownID = group(Town)

*eststo clear

* Dependent variable: Buy-sell imbalance for low-tech stocks
* With client fixed effects
reghdfe LowTechBuySellImbalancePerM ///
InflationIHS ///
, absorb(ClientID MonthID) cluster(TownID MonthID) keepsingletons
eststo Inflation4

* Compare coefficient estimates of low-tech stocks and high-tech stocks
preserve
keep ClientNr Month LowTechBuySellImbalancePerM InflationIHS ///
ClientID MonthID TownID

rename LowTechBuySellImbalancePerM LowHighTechBuySellImbalancePerM

gen HighTech = 0

save "LowTechStocksClientLevel.dta", replace
restore



* Compare coefficient estimates of low-tech stocks and high-tech stocks
use "LowTechStocksClientLevel.dta", clear

append using "HighTechStocksClientLevel.dta"

* Generate numerical IDs
egen MonthTechID = group(MonthID HighTech)
egen ClientTechID = group(ClientID HighTech)
egen TownTechID = group(TownID HighTech)

* Interaction variables
gen InflationIHS_HighTech = InflationIHS * HighTech
label var InflationIHS_HighTech "Local inflation$^{}_{i,t}$ $\times$ High tech (d)"

*eststo clear

* Dependent variable: Buy-sell imbalance for low-tech/high-tech stocks
reghdfe LowHighTechBuySellImbalancePerM ///
InflationIHS InflationIHS_HighTech ///
, absorb(ClientTechID MonthTechID) cluster(TownTechID MonthTechID) keepsingletons

test _b[InflationIHS_HighTech] = 0

erase "LowTechStocksClientLevel.dta"
erase "HighTechStocksClientLevel.dta"



* Low-volatility stocks
use "GermanHyperinflationClientLevel.dta", clear

* Restrict sample to January 1920 to September 1923
drop if Month < ym(1920,1)
drop if Month > ym(1923,9)

* The place for which we have inflation data has to be in a 25km radius of where the client lives
drop if DistanceToTown > 25

* Keep only German clients
keep if Country == "Germany"

* Drop clients who do not trade
drop if NumberOfTrades == 0

* Generate numerical IDs
egen ClientID = group(ClientNr)
egen MonthID = group(Month)
egen TownID = group(Town)

*eststo clear

* Dependent variable: Buy-sell imbalance for low-volatility stocks
reghdfe LowVolaBuySellImbalancePerM ///
InflationIHS ///
, absorb(ClientID MonthID) cluster(TownID MonthID) keepsingletons
eststo Inflation5

* Compare coefficient estimates of low-volatility stocks and high-volatility stocks
preserve
keep ClientNr Month LowVolaBuySellImbalancePerM InflationIHS ///
ClientID MonthID TownID

rename LowVolaBuySellImbalancePerM LowHighVolaBuySellImbalancePerM

gen HighVola = 0

save "LowVolatilityStocksClientLevel.dta", replace
restore



* High-volatility stocks
use "GermanHyperinflationClientLevel.dta", clear

* Restrict sample to January 1920 to September 1923
drop if Month < ym(1920,1)
drop if Month > ym(1923,9)

* The place for which we have inflation data has to be in a 25km radius of where the client lives
drop if DistanceToTown > 25

* Keep only German clients
keep if Country == "Germany"

* Drop clients who do not trade
drop if NumberOfTrades == 0

* Generate numerical IDs
egen ClientID = group(ClientNr)
egen MonthID = group(Month)
egen TownID = group(Town)

*eststo clear

* Dependent variable: Buy-sell imbalance for high-volatility stocks
reghdfe HighVolaBuySellImbalancePerM ///
InflationIHS ///
, absorb(ClientID MonthID) cluster(TownID MonthID) keepsingletons
eststo Inflation6

* Compare coefficient estimates of low-volatility stocks and high-volatility stocks
preserve
keep ClientNr Month HighVolaBuySellImbalancePerM InflationIHS ///
ClientID MonthID TownID

rename HighVolaBuySellImbalancePerM LowHighVolaBuySellImbalancePerM

gen HighVola = 1

save "HighVolatilityStocksClientLevel.dta", replace
restore



* Compare coefficient estimates of low-volatility stocks and high-volatility stocks
use "LowVolatilityStocksClientLevel.dta", clear

append using "HighVolatilityStocksClientLevel.dta"

* Generate numerical IDs
egen MonthVolaID = group(MonthID HighVola)
egen ClientVolaID = group(ClientID HighVola)
egen TownVolaID = group(TownID HighVola)

* Interaction variables
gen InflationIHS_HighVola = InflationIHS * HighVola
label var InflationIHS_HighVola "Local inflation$^{}_{i,t}$ $\times$ High volatility (d)"

*eststo clear

* Dependent variable: Buy-sell imbalance for low-volatility/high-volatility stocks
reghdfe LowHighVolaBuySellImbalancePerM ///
InflationIHS InflationIHS_HighVola ///
, absorb(ClientVolaID MonthVolaID) cluster(TownVolaID MonthVolaID) keepsingletons

test _b[InflationIHS_HighVola] = 0

erase "LowVolatilityStocksClientLevel.dta"
erase "HighVolatilityStocksClientLevel.dta"



* Low-beta stocks
use "GermanHyperinflationClientLevel.dta", clear

* Restrict sample to January 1920 to September 1923
drop if Month < ym(1920,1)
drop if Month > ym(1923,9)

* The place for which we have inflation data has to be in a 25km radius of where the client lives
drop if DistanceToTown > 25

* Keep only German clients
keep if Country == "Germany"

* Drop clients who do not trade
drop if NumberOfTrades == 0

* Generate numerical IDs
egen ClientID = group(ClientNr)
egen MonthID = group(Month)
egen TownID = group(Town)

*eststo clear

* Dependent variable: Buy-sell imbalance for low-beta stocks
reghdfe LowBetaBuySellImbalancePerM ///
InflationIHS ///
, absorb(ClientID MonthID) cluster(TownID MonthID) keepsingletons
eststo Inflation7

* Compare coefficient estimates of low-beta stocks and high-beta stocks
preserve
keep ClientNr Month LowBetaBuySellImbalancePerM InflationIHS ///
ClientID MonthID TownID

rename LowBetaBuySellImbalancePerM LowHighBetaBuySellImbalancePerM

gen HighBeta = 0

save "LowBetaStocksClientLevel.dta", replace
restore



* High-beta stocks
use "GermanHyperinflationClientLevel.dta", clear

* Restrict sample to January 1920 to September 1923
drop if Month < ym(1920,1)
drop if Month > ym(1923,9)

* The place for which we have inflation data has to be in a 25km radius of where the client lives
drop if DistanceToTown > 25

* Keep only German clients
keep if Country == "Germany"

* Drop clients who do not trade
drop if NumberOfTrades == 0

* Generate numerical IDs
egen ClientID = group(ClientNr)
egen MonthID = group(Month)
egen TownID = group(Town)

*eststo clear

* Dependent variable: Buy-sell imbalance for high-beta stocks
reghdfe HighBetaBuySellImbalancePerM ///
InflationIHS ///
, absorb(ClientID MonthID) cluster(TownID MonthID) keepsingletons
eststo Inflation8

* Compare coefficient estimates of low-beta stocks and high-beta stocks
preserve
keep ClientNr Month HighBetaBuySellImbalancePerM InflationIHS ///
ClientID MonthID TownID

rename HighBetaBuySellImbalancePerM LowHighBetaBuySellImbalancePerM

gen HighBeta = 1

save "HighBetaStocksClientLevel.dta", replace
restore



* Compare coefficient estimates of low-beta stocks and high-beta stocks
use "LowBetaStocksClientLevel.dta", clear

append using "HighBetaStocksClientLevel.dta"

* Generate numerical IDs
egen MonthBetaID = group(MonthID HighBeta)
egen ClientBetaID = group(ClientID HighBeta)
egen TownBetaID = group(TownID HighBeta)

* Interaction variables
gen InflationIHS_HighBeta = InflationIHS * HighBeta
label var InflationIHS_HighBeta "Local inflation$^{}_{i,t}$ $\times$ High beta (d)"

*eststo clear

* Dependent variable: Buy-sell imbalance for low-beta/high-beta stocks
reghdfe LowHighBetaBuySellImbalancePerM ///
InflationIHS InflationIHS_HighBeta ///
, absorb(ClientBetaID MonthBetaID) cluster(TownBetaID MonthBetaID) keepsingletons

test _b[InflationIHS_HighBeta] = 0

erase "LowBetaStocksClientLevel.dta"
erase "HighBetaStocksClientLevel.dta"



estout using "tables/table6A.tex", replace ///
keep( ) ///
style(tex) label numbers mlabels(, none) collabels(, none) margin eqlabels(none) ///
posthead(\hline) ///
cells(b(star fmt(%9.3f)) t(par fmt(%9.2f))) ///
starlevels(* 0.10 ** 0.05 *** 0.01)

estout using "tables/table6B.tex", replace ///
keep(InflationIHS) ///
eqlabels(none) ///
style(tex) label mlabels(, none) collabels(, none) margin ///
cells(b(star fmt(%9.3f)) t(par fmt(%9.2f))) ///
starlevels(* 0.10 ** 0.05 *** 0.01)

estout using "tables/table6C.tex", replace ///
keep( ) ///
style(tex) label mlabels(, none) collabels(, none) margin eqlabels(none) ///
cells(b(star fmt(%9.3f)) t(par fmt(%9.2f))) ///
starlevels(* 0.10 ** 0.05 *** 0.01) ///
stats(r2_a N, labels("Adj. R\textsuperscript{2}" "N") fmt(%9.3fc %9.0fc))



*------------------------------------------------------------------------------
* Table 7: Local inflation and the performance of stock sales
*------------------------------------------------------------------------------

use "GermanHyperinflationSecurityLevel.dta", clear

* Restrict sample to January 1920 to September 1923
drop if Month < ym(1920,1)
drop if Month > ym(1923,9)

* The place for which we have inflation data has to be in a 25km radius of where the client lives
drop if DistanceToTown > 25

* Keep only German clients
keep if Country == "Germany"

* Keep only stocks
keep if AssetClass == "Equity"

* Generate numerical IDs
egen ClientID = group(ClientNr)
egen MonthID = group(Month)
egen TownID = group(Town)
egen IssuerID = group(IssuerNr)

* Winsorize
sum SecurityReturnRealNext3M, det
winsor SecurityReturnRealNext3M, gen(tmp) p(0.01)
replace SecurityReturnRealNext3M = tmp
drop tmp
sum SecurityReturnRealNext3M, det

sum SecurityReturnRealNext6M, det
winsor SecurityReturnRealNext6M, gen(tmp) p(0.01)
replace SecurityReturnRealNext6M = tmp
drop tmp
sum SecurityReturnRealNext6M, det

eststo clear

* Dependent variable: Real return of stock sales over next 3 months
* With time fixed effects
reghdfe SecurityReturnRealNext3M ///
InflationIHS ///
if NumberOfStockSellsPerM > 0 & !mi(NumberOfStockSellsPerM) ///
, absorb(MonthID) cluster(TownID MonthID) keepsingletons
eststo Inflation1

* With time and firm fixed effects
reghdfe SecurityReturnRealNext3M ///
InflationIHS ///
if NumberOfStockSellsPerM > 0 & !mi(NumberOfStockSellsPerM) ///
, absorb(MonthID IssuerID) cluster(TownID MonthID) keepsingletons
eststo Inflation2

* With time, client, and firm fixed effects
reghdfe SecurityReturnRealNext3M ///
InflationIHS ///
if NumberOfStockSellsPerM > 0 & !mi(NumberOfStockSellsPerM) ///
, absorb(ClientID MonthID IssuerID) cluster(TownID MonthID) keepsingletons
eststo Inflation3

* Dependent variable: Real return of stock sales over next 6 months
* With time, client, and issuer fixed effects
reghdfe SecurityReturnRealNext6M ///
InflationIHS ///
if NumberOfStockSellsPerM > 0 & !mi(NumberOfStockSellsPerM) ///
, absorb(ClientID MonthID IssuerID) cluster(TownID MonthID) keepsingletons
eststo Inflation4



estout using "tables/table7A.tex", replace ///
keep( ) ///
style(tex) label numbers mlabels(, none) collabels(, none) margin eqlabels(none) ///
posthead(\hline) ///
cells(b(star fmt(%9.3f)) t(par fmt(%9.2f))) ///
starlevels(* 0.10 ** 0.05 *** 0.01)

estout using "tables/table7B.tex", replace ///
keep(InflationIHS) ///
eqlabels(none) ///
style(tex) label mlabels(, none) collabels(, none) margin ///
cells(b(star fmt(%9.3f)) t(par fmt(%9.2f))) ///
starlevels(* 0.10 ** 0.05 *** 0.01)

estout using "tables/table7C.tex", replace ///
keep( ) ///
style(tex) label mlabels(, none) collabels(, none) margin eqlabels(none) ///
cells(b(star fmt(%9.3f)) t(par fmt(%9.2f))) ///
starlevels(* 0.10 ** 0.05 *** 0.01) ///
stats(r2_a N, labels("Adj. R\textsuperscript{2}" "N") fmt(%9.3fc %9.0fc))



*------------------------------------------------------------------------------
* Table 8: Local inflation and individual stock trades
*------------------------------------------------------------------------------

use "GermanHyperinflationSecurityLevel.dta", clear

* Restrict sample to January 1920 to September 1923
drop if Month < ym(1920,1)
drop if Month > ym(1923,9)

* The place for which we have inflation data has to be in a 25km radius of where the client lives
drop if DistanceToTown > 25

* Keep only German clients
keep if Country == "Germany"

* Generate numerical IDs
egen ClientID = group(ClientNr)
egen MonthID = group(Month)
egen TownID = group(Town)
egen SecurityID = group(SecurityNr)
egen SecurityMonthID = group(SecurityNr Month)

eststo clear

* Dependent variable: Buy-sell imbalance for stocks
* With time fixed effects
reghdfe StockBuySellImbalancePerM ///
InflationIHS ///
, absorb(MonthID) cluster(TownID MonthID) keepsingletons
eststo Inflation1

* With time and client fixed effects
reghdfe StockBuySellImbalancePerM ///
InflationIHS ///
, absorb(ClientID MonthID) cluster(TownID MonthID) keepsingletons
eststo Inflation2

* With time, client, and security fixed effects
reghdfe StockBuySellImbalancePerM ///
InflationIHS ///
, absorb(ClientID MonthID SecurityID) cluster(TownID MonthID) keepsingletons
eststo Inflation3

* With client and security-time fixed effects
reghdfe StockBuySellImbalancePerM ///
InflationIHS ///
, absorb(ClientID SecurityMonthID) cluster(TownID MonthID) keepsingletons
eststo Inflation4

* Past 2-month inflation
reghdfe StockBuySellImbalancePerM ///
InflationPast2MIHS ///
, absorb(ClientID SecurityMonthID) cluster(TownID MonthID) keepsingletons
eststo Inflation5

* With client and security-time fixed effects and controls
reghdfe StockBuySellImbalancePerM ///
InflationIHS ///
Occupied UnemploymentRateImputed ///
, absorb(ClientID SecurityMonthID) cluster(TownID MonthID) keepsingletons
eststo Inflation6



estout using "tables/table8A.tex", replace ///
keep( ) ///
style(tex) label numbers mlabels(, none) collabels(, none) margin eqlabels(none) ///
posthead(\hline) ///
cells(b(star fmt(%9.3f)) t(par fmt(%9.2f))) ///
starlevels(* 0.10 ** 0.05 *** 0.01)

estout using "tables/table8B.tex", replace ///
keep(InflationIHS InflationPast2MIHS Occupied UnemploymentRateImputed) ///
eqlabels(none) ///
style(tex) label mlabels(, none) collabels(, none) margin ///
cells(b(star fmt(%9.3f)) t(par fmt(%9.2f))) ///
starlevels(* 0.10 ** 0.05 *** 0.01)

estout using "tables/table8C.tex", replace ///
keep( ) ///
style(tex) label mlabels(, none) collabels(, none) margin eqlabels(none) ///
cells(b(star fmt(%9.3f)) t(par fmt(%9.2f))) ///
starlevels(* 0.10 ** 0.05 *** 0.01) ///
stats(r2_a N, labels("Adj. R\textsuperscript{2}" "N") fmt(%9.3fc %9.0fc))



*------------------------------------------------------------------------------
* Table 9: Local inflation and bond trades
*------------------------------------------------------------------------------

* Client-level analysis
use "GermanHyperinflationClientLevel.dta", clear

* Restrict sample to January 1920 to September 1923
drop if Month < ym(1920,1)
drop if Month > ym(1923,9)

* The place for which we have inflation data has to be in a 25km radius of where the client lives
drop if DistanceToTown > 25

* Keep only German clients
keep if Country == "Germany"

* Drop clients who do not trade
drop if NumberOfTrades == 0

* Generate numerical IDs
egen ClientID = group(ClientNr)
egen MonthID = group(Month)
egen TownID = group(Town)

eststo clear

* Dependent variable: Buy-sell imbalance for bonds
* With time fixed effects
reghdfe BondBuySellImbalancePerM ///
InflationIHS ///
, absorb(MonthID) cluster(TownID MonthID) keepsingletons
eststo Inflation1

* With time and client fixed effects
reghdfe BondBuySellImbalancePerM ///
InflationIHS ///
, absorb(ClientID MonthID) cluster(TownID MonthID) keepsingletons
eststo Inflation2

* Past 2-month inflation
reghdfe BondBuySellImbalancePerM ///
InflationPast2MIHS ///
, absorb(ClientID MonthID) cluster(TownID MonthID) keepsingletons
eststo Inflation3

* With time and client fixed effects and controls
reghdfe BondBuySellImbalancePerM ///
InflationIHS ///
Occupied UnemploymentRateImputed ///
, absorb(ClientID MonthID) cluster(TownID MonthID) keepsingletons
eststo Inflation4



* Security-level analysis
use "GermanHyperinflationSecurityLevel.dta", clear

* Restrict sample to January 1920 to September 1923
drop if Month < ym(1920,1)
drop if Month > ym(1923,9)

* The place for which we have inflation data has to be in a 25km radius of where the client lives
drop if DistanceToTown > 25

* Keep only German clients
keep if Country == "Germany"

* Generate numerical IDs
egen ClientID = group(ClientNr)
egen MonthID = group(Month)
egen TownID = group(Town)
egen SecurityID = group(SecurityNr)
egen SecurityMonthID = group(SecurityNr Month)

*eststo clear

* Dependent variable: Buy-sell imbalance for bonds
* With client and security-time fixed effects
reghdfe BondBuySellImbalancePerM InflationIHS, absorb(ClientID SecurityMonthID) cluster(TownID MonthID) keepsingletons
eststo Inflation5

* Past 2-month inflation
reghdfe BondBuySellImbalancePerM InflationPast2MIHS, absorb(ClientID SecurityMonthID) cluster(TownID MonthID) keepsingletons
eststo Inflation6

* With client and security-time fixed effects and controls
reghdfe BondBuySellImbalancePerM ///
InflationIHS ///
Occupied UnemploymentRateImputed ///
, absorb(ClientID SecurityMonthID) cluster(TownID MonthID) keepsingletons
eststo Inflation7



estout using "tables/table9A.tex", replace ///
keep( ) ///
style(tex) label numbers mlabels(, none) collabels(, none) margin eqlabels(none) ///
posthead(\hline) ///
cells(b(star fmt(%9.3f)) t(par fmt(%9.2f))) ///
starlevels(* 0.10 ** 0.05 *** 0.01)

estout using "tables/table9B.tex", replace ///
keep(InflationIHS InflationPast2MIHS) ///
eqlabels(none) ///
style(tex) label mlabels(, none) collabels(, none) margin ///
cells(b(star fmt(%9.3f)) t(par fmt(%9.2f))) ///
starlevels(* 0.10 ** 0.05 *** 0.01)

estout using "tables/table9C.tex", replace ///
keep(Occupied UnemploymentRateImputed) ///
eqlabels(none) ///
style(tex) label mlabels(, none) collabels(, none) margin ///
cells(b(star fmt(%9.3f)) t(par fmt(%9.2f))) ///
starlevels(* 0.10 ** 0.05 *** 0.01)

estout using "tables/table9D.tex", replace ///
keep( ) ///
style(tex) label mlabels(, none) collabels(, none) margin eqlabels(none) ///
cells(b(star fmt(%9.3f)) t(par fmt(%9.2f))) ///
starlevels(* 0.10 ** 0.05 *** 0.01) ///
stats(r2_a N, labels("Adj. R\textsuperscript{2}" "N") fmt(%9.3fc %9.0fc))



*------------------------------------------------------------------------------
* Table 10: Local inflation and trades in securities denominated in foreign currencies
*------------------------------------------------------------------------------

* Client-level analysis
use "GermanHyperinflationClientLevel.dta", clear

* Restrict sample to January 1920 to September 1923
drop if Month < ym(1920,1)
drop if Month > ym(1923,9)

* The place for which we have inflation data has to be in a 25km radius of where the client lives
drop if DistanceToTown > 25

* Keep only German clients
keep if Country == "Germany"

* Drop clients who do not trade
drop if NumberOfTrades == 0

* Generate numerical IDs
egen ClientID = group(ClientNr)
egen MonthID = group(Month)
egen TownID = group(Town)

eststo clear

* Dependent variable: Buy-sell imbalance for securities denominated in foreign currencies
* With time fixed effects
reghdfe ForexBuySellImbalancePerM ///
InflationIHS ///
, absorb(MonthID) cluster(TownID MonthID) keepsingletons
eststo Inflation1

* With time and client fixed effects
reghdfe ForexBuySellImbalancePerM ///
InflationIHS ///
, absorb(ClientID MonthID) cluster(TownID MonthID) keepsingletons
eststo Inflation2

* Past 2-month inflation
reghdfe ForexBuySellImbalancePerM ///
InflationPast2MIHS ///
, absorb(ClientID MonthID) cluster(TownID MonthID) keepsingletons
eststo Inflation3

* With time and client fixed effects and controls
reghdfe ForexBuySellImbalancePerM ///
InflationIHS ///
Occupied UnemploymentRateImputed ///
, absorb(ClientID MonthID) cluster(TownID MonthID) keepsingletons
eststo Inflation4



* Security-level analysis
use "GermanHyperinflationSecurityLevel.dta", clear

* Restrict sample to January 1920 to September 1923
drop if Month < ym(1920,1)
drop if Month > ym(1923,9)

* The place for which we have inflation data has to be in a 25km radius of where the client lives
drop if DistanceToTown > 25

* Keep only German clients
keep if Country == "Germany"

* Generate numerical IDs
egen ClientID = group(ClientNr)
egen MonthID = group(Month)
egen TownID = group(Town)
egen SecurityID = group(SecurityNr)
egen SecurityMonthID = group(SecurityNr Month)

*eststo clear

* Dependent variable: Buy-sell imbalance for securities denominated in foreign currencies
* With client and security-time fixed effects
reghdfe ForexBuySellImbalancePerM ///
InflationIHS ///
, absorb(ClientID SecurityMonthID) cluster(TownID MonthID) keepsingletons
eststo Inflation5

* Past 2-month inflation
reghdfe ForexBuySellImbalancePerM ///
InflationPast2MIHS ///
, absorb(ClientID SecurityMonthID) cluster(TownID MonthID) keepsingletons
eststo Inflation6

* With client and security-time fixed effects and controls
reghdfe ForexBuySellImbalancePerM ///
InflationIHS ///
Occupied UnemploymentRateImputed ///
, absorb(ClientID SecurityMonthID) cluster(TownID MonthID) keepsingletons
eststo Inflation7



estout using "tables/table10A.tex", replace ///
keep( ) ///
style(tex) label numbers mlabels(, none) collabels(, none) margin eqlabels(none) ///
posthead(\hline) ///
cells(b(star fmt(%9.3f)) t(par fmt(%9.2f))) ///
starlevels(* 0.10 ** 0.05 *** 0.01)

estout using "tables/table10B.tex", replace ///
keep(InflationIHS InflationPast2MIHS) ///
eqlabels(none) ///
style(tex) label mlabels(, none) collabels(, none) margin ///
cells(b(star fmt(%9.3f)) t(par fmt(%9.2f))) ///
starlevels(* 0.10 ** 0.05 *** 0.01)

estout using "tables/table10C.tex", replace ///
keep(Occupied UnemploymentRateImputed) ///
eqlabels(none) ///
style(tex) label mlabels(, none) collabels(, none) margin ///
cells(b(star fmt(%9.3f)) t(par fmt(%9.2f))) ///
starlevels(* 0.10 ** 0.05 *** 0.01)

estout using "tables/table10D.tex", replace ///
keep( ) ///
style(tex) label mlabels(, none) collabels(, none) margin eqlabels(none) ///
cells(b(star fmt(%9.3f)) t(par fmt(%9.2f))) ///
starlevels(* 0.10 ** 0.05 *** 0.01) ///
stats(r2_a N, labels("Adj. R\textsuperscript{2}" "N") fmt(%9.3fc %9.0fc))



*------------------------------------------------------------------------------
* Figure 1: Local inflation and stock trades
*------------------------------------------------------------------------------

use "GermanHyperinflationClientLevel.dta", clear

* Restrict sample to January 1920 to September 1923
drop if Month < ym(1920,1)
drop if Month > ym(1923,9)

* The place for which we have inflation data has to be in a 25km radius of where the client lives
drop if DistanceToTown > 25

* Keep only German clients
keep if Country == "Germany"

* Drop clients who do not trade
drop if NumberOfTrades == 0

* Groups based on inflation deciles
collapse ///
(mean) StockBuySellImbalanceMean = StockBuySellImbalancePerM ///
(sd) StockBuySellImbalanceStdDev = StockBuySellImbalancePerM ///
(count) StockBuySellImbalanceN = StockBuySellImbalancePerM ///
, by(InflationDecile)

* 99% confidence interval
gen StockBuySellImbalanceUpperBound = StockBuySellImbalanceMean ///
+ invttail(StockBuySellImbalanceN-1, 0.005) * sqrt(StockBuySellImbalanceStdDev / StockBuySellImbalanceN)
gen StockBuySellImbalanceLowerBound = StockBuySellImbalanceMean ///
- invttail(StockBuySellImbalanceN-1, 0.005) * sqrt(StockBuySellImbalanceStdDev / StockBuySellImbalanceN)



graph twoway (bar StockBuySellImbalanceMean InflationDecile, barw(.8) yaxis(1) lc(black) fcolor(gs12)) ///
(rcap StockBuySellImbalanceUpperBound StockBuySellImbalanceLowerBound InflationDecile, lc(black)), ///
xlabel(1 "1" 2 "2" 3 "3" 4 "4" 5 "5" 6 "6" 7 "7" 8 "8" 9 "9" 10 "10") ///
yline(0, lc(black)) ///
xtitle("Local inflation decile{subscript:i,t}") ///
ytitle("Buy-sell imbalance for stocks{subscript:i,t}") ///
legend(order(1 "Buy-sell imbalance" 2 "99% confidence interval") col(2)) ///
graphregion(color(white))
graph export "figures/Figure1.png", replace width(4000)



*------------------------------------------------------------------------------
* Figure 2: Nominal prices
*------------------------------------------------------------------------------

use "GermanHyperinflationNominalPrices.dta", clear

* Rescale variables
egen Minimum = min(Month)
foreach var in CPI StockMarketIndex Dollar DeutscheReichsschatzanweisung RealEstate {
gen tmp = `var' if Month == Minimum
egen tmptmp = max(tmp)
replace `var' = `var' / tmptmp
drop tmp tmptmp
}
drop Minimum


graph twoway (line CPI Month, lcolor(black)) ///
(line StockMarketIndex Month, lpattern(dash) lcolor(black)) ///
(line Dollar Month, lpattern(dash) lcolor(gs10)) ///
(line DeutscheReichsschatzanweisung Month, lpattern("-") lcolor(gs10)) ///
(line RealEstate Month, lpattern(longdash) lcolor(gs10)), ///
yscale(log) ///
ylabel(1 "1" 10 "10" 100 "100" 1000 "10{superscript:3}" 10000 "10{superscript:4}" 100000 "10{superscript:5}" 1000000 "10{superscript:6}" 10000000 "10{superscript:7}") ///
ytitle("Nominal value (February 1920 = 1)" " ") ///
xlabel(-474.5 "1920" -462.5 "1921" -450.5 "1922" -438.5 "1923",tstyle(major_notick)) ///
xtick(-432.5(12)-468.5, tstyle(major_nolabel)) ///
tline(-465, lstyle(foreground) lpattern(dash)) ///
text(20000000 -465 "Allies set reparations", place(sw) just(left) orient(vertical)) ///
tline(-461, lstyle(foreground) lpattern(dash)) ///
text(20000000 -461 "Erzberger assassinated", place(sw) just(left) orient(vertical)) ///
tline(-454, lstyle(foreground) lpattern(dash)) ///
text(20000000 -454 "Germany deregulates housing rents", place(sw) just(left) orient(vertical)) ///
tline(-451, lstyle(foreground) lpattern(dash)) ///
text(20000000 -451 "Rathenau assassinated", place(sw) just(left) orient(vertical)) ///
tline(-447, lstyle(foreground) lpattern(dash)) ///
text(20000000 -447 "Germany restricts Forex", place(sw) just(left) orient(vertical)) ///
tline(-444.5, lstyle(foreground) lpattern(dash)) ///
text(20000000 -444.5 "France/Belgium occupy Ruhr", place(sw) just(left) orient(vertical)) ///
tline(-435.5, lstyle(foreground) lpattern(dash)) ///
text(20000000 -435.5 "Germany reforms its currency", place(se) just(left) orient(vertical)) ///
graphregion(color(white))
graph export "figures/Figure2.png", replace width(4000)


		
*------------------------------------------------------------------------------
* Figure 3: Local inflation
*------------------------------------------------------------------------------

use "GermanHyperinflationTownLevel.dta", clear

graph twoway scatter InflationIHS Month, ///
msize(vtiny) mcolor(black)  ///
xlabel(-474.5 "1920" -462.5 "1921" -450.5 "1922" -438.5 "1923" -426.5 "1924",tstyle(major_notick)) ///
xtick(-432.5(12)-480.5, tstyle(major_nolabel)) ///
xtitle("") ///
ytitle("Local inflation{subscript:c,t}") ///
graphregion(color(white))
graph export "figures/Figure3.png", replace width(4000)
